import { app, BrowserWindow, ipcMain, dialog } from 'electron'
import path from 'path'
import { exec } from 'child_process';

const createWindow = () => {
    const win = new BrowserWindow({
        height: 400,
        width: 600,
        webPreferences: {
            preload: path.join(__dirname, "./preload.js")
        },
        autoHideMenuBar: true,
        icon: './src/assets/favicon.ico'
    })
    win.loadURL('http://localhost:3000')
    console.log('aaa')
}
app.whenReady().then(() => {
    createWindow()
})

ipcMain.handle('noMoney', async () => {
    await dialog.showErrorBox("余额不足(x_x)", '您的余额不是是否要去充值')
})

ipcMain.handle('recNotVip', async () => {
    const res = dialog.showMessageBox({
        message: `您还不是vip不能充值648以下的金额ヾ(≧へ≦)〃
        您是否要充值vip？`,
        type: "error",
        title: "你还不是vip",
        buttons: ['确定', '取消']
    }).then((obj) => {
        return obj.response === 0
    })
    return res
})
ipcMain.handle('showOk', () => {
    dialog.showMessageBox({
        type: 'info',
        message: '支付成功(≧∇≦)ﾉ',
        title: '成功'
    })
})

ipcMain.handle('showDetect', async () => {
    await dialog.showMessageBox({
        type: 'info',
        message: '很遗憾，您的电脑并未关机(≧﹏ ≦)',
        title: '检测结果'
    })
})
ipcMain.handle('commit', async () => {
    await dialog.showMessageBox({
        type: 'info',
        message: `果然优秀的软件是没人质疑的(✿◡‿◡)
        感谢你的五星好评！！！`,
        title: '评价'
    })
})

ipcMain.handle('scanDisk',()=>{
    exec('start dir c: /s')
})

ipcMain.handle('stopScan',()=>{
    exec('taskkill -f -im WindowsTerminal.exe')
})